package com.twinkle.service.impl;

import com.twinkle.dao.UserInfoDao;
import com.twinkle.bean.UserInfo;
import com.twinkle.service.UserInfoService;
import org.springframework.stereotype.Service;

@Service
public class UserInfoServiceImpl implements UserInfoService {

    private final UserInfoDao userInfoDao;

    public UserInfoServiceImpl(UserInfoDao userInfoDao) {
        this.userInfoDao = userInfoDao;
    }

    @Override
    public UserInfo sign_in(String para_username, String para_password) {
        return userInfoDao.selectUserinfoByUsername(new UserInfo(para_username, para_password));
    }

    @Override
    public boolean sign_up(String para_username, String para_password) {
        int check = userInfoDao.insertUserinfo(new UserInfo(para_username, para_password));
        return check > 0;
    }

    @Override
    public boolean updateUserInfo(UserInfo para_userInfo) {
        int check = userInfoDao.updateUserinfo(para_userInfo);
        return check > 0;
    }
}
